<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.zjf.entity.Article"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.net.URLDecoder"%>
<%@ include file= "loadDatas.jsp"%>
<%!
	List<Article> articles = new ArrayList<Article>();
	
%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
articles = (ArrayList)application.getAttribute("articles");
List<Article> loads = new ArrayList<Article>();
String load = request.getParameter("load");
String type = request.getParameter("type");
if(load!=null && !load.equals("")){
	SimpleDateFormat format = new SimpleDateFormat("yyyyMM");
	Date d = format.parse(load);
	for(Article a:articles){
		SimpleDateFormat f = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
		Date pd = f.parse(a.getPubDate());
		System.out.println(pd.getMonth());
		System.out.println(d.getMonth());
		if(pd.getMonth()==d.getMonth() && pd.getYear() == d.getYear()){
			loads.add(a);
		}
	}
}else if(type!=null && !type.equals("")){
	for(Article a:articles){
		//System.out.println(type);
		//System.out.println(new String(type.getBytes("ISO-8859-1"),"GBK"));
		
		if(a.getTitle().contains(new String(type.getBytes("ISO-8859-1"),"GBK"))){
		
			loads.add(a);
		}
	}
}else{
	loads = articles;
}
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>articles</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="style/style.css" />

  </head>
  <body>
    <center>
    <div id ="wrap">
		
	
			<jsp:include page="head.jsp"></jsp:include>
			
			<div id="center_pad1">
				<%for(Article a:loads){ %>
					<a href="article-<%=a.getId() %>.html"><%=a.getTitle() %>----【<%=a.getPubDate() %>】</a></br>
				<%} %>
			</div>
			
			<jsp:include page="foot.jsp"></jsp:include>
  </div>
  </body>
</html>
